//
//  RobotSystem.h
//  RobotCleaner
//
//  Created by hcl on 2022/5/19.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

// 弹框点击确认时候需要执行的数据
typedef void (^sure_click)(void);
// 弹框点击取消时候需要执行的数据
typedef void (^cancel_click)(void);

@interface RobotSystem : NSObject

/*! @brief 判断是否为空 为空则return yes
 *
 */
BOOL judgeIsNULL(id obj);

/*! @brief 判断字符串是否为空 为空Or不是NSSring类 则return yes
 *
 */
BOOL judgeStringIsNULL(id obj);

/*! @brief 判断数组是否为空 为空Or不是NSArray类 则return yes
 *
 */
BOOL judgeArrayIsNULL(id obj);

/*! @brief 判断字典是否为空 为空Or不是NSDictionary类 则return yes
 *
 */
BOOL judgeDictionaryIsNULL(id obj);

NSString *securityString(id obj);

NSArray *securityArray(id obj);

NSDictionary *securityDictionary(id obj);

/**  对一个字符串进行base64编码，并返回  */
NSString *base64EncodeString(id obj);

/**  对一个base64编码后的字符串解码  */
NSString *base64DecodeString(id obj);

/**  指定范围内的随机数 仅支持正整数 */
NSInteger getRandomNumberFrom(NSInteger fromNum, NSInteger toNum);

/**  获取n位随机数 0~9 a~z A~Z  最大为256位*/
NSString *getRandomNumberWithX_Length(int length);

/**  字典转Json字符串  */
NSString *dicConvertToJsonString(id infoDict);

/**  JSON字符串转化为字典  */
NSDictionary *jsonStringConvertToDic(NSString *jsonString);

/**  小数转换为NSString  */
NSString *getStringFromDoubleVal(double doubleVal);

/**  保留n位小数不四舍五入  */
NSString *getStringFromFloatVal(double floatVal, int decimalsLength);

/*! @brief 通过归解档来深拷贝数组
 *
 */
NSArray *trueDeepCopyArray(id obj);

/**  限制字符串长度为limit 并且拼接...  */
NSString *limtStringWithTrail(NSString *str, NSInteger limit);

/*! @brief 限制数字输入
 @ para maxNum 最大数字
 @ para decimalsLength 小数的长度
 *
 */
void limitInputNumber(UITextField *textField, NSString *maxNum, int decimalsLength);

/*! @brief 限制数字输入
 @ para maxNum 最大数字
 @ para decimalsLength 小数的长度
 @ para moreThanMaxNumberBlock 超过最大数字时的block
 @ para moreThanDecimalsLengthBlock 超过最小数长度时的block
 *
 */
void limitInputNumberWihthBlock(UITextField *textField,
                                NSString *maxNum,
                                int decimalsLength,
                                void (^moreThanMaxNumberBlock)(void),
                                void (^moreThanDecimalsLengthBlock)(void));

/*! @brief 限制货币8位小数
 *
 */
NSString *limitHuoBiNumber(id obj);

/*! @brief 数字转换 例如 10900 = 1.1万
 *
 */
NSString *shortedNumberDesc(id numberStr);

/*! @brief 剔除空格
 *
 */
NSString *trimmingWhitespaceWith(NSString *str);

/*
 手机号码合法性验证
 */
BOOL isValidTelNumber(id numberStr);

/*! @brief 如果是手机号则转换为安全手机号 例如138****6689
 *
 */
NSString *stringConvertToSecretMobile(NSString *mobileStr);

/**  用户名转换  */
NSString *usernameConvertToSecretMobile(NSString *name, NSInteger limte);

/**
 对字典(Key-Value)排序 区分大小写 升序

 @param dict 要排序的字典
 */
NSArray *sortedDictionary(NSDictionary *dict);

/*! @brief 价格
 *
 */
NSMutableAttributedString *priceAttStringWithScoreString(NSString *priceStr, UIFont *integerFont, UIFont *decimalFont);

/*! @brief 价格 --> 带颜色
 *
 */
NSMutableAttributedString *priceAttStringWithScoreStringAndSymbolwithcoloer(NSString *symbol, NSString *priceStr, UIFont *symbolFont, UIFont *integerFont, UIFont *decimalFont, UIColor *textCorlor);

/*! @brief 带符号的价格
 *
 */
NSMutableAttributedString *priceAttStringWithScoreStringAndSymbol(NSString *symbol, NSString *priceStr, UIFont *symbolFont, UIFont *integerFont, UIFont *decimalFont);

/**  按分割长度 和分割字符(默认封符@“ ”) 来分割字符长  */
NSString *segmentationString(NSString *str, NSInteger blockLengtn, NSString *insertStr);

/*! @brief 将图片按比例压缩到自定宽度
 *
 */
UIImage *imageScaleToWidth(UIImage *originImg, CGFloat width);

/*! @brief 画水印
 *
 */
UIImage *imageWithWaterMask(UIImage *originImg, UIImage *mask, CGRect inRect);

/*! @brief 拨打电话
 *
 */
+ (void)callServerPhone:(NSString *)phoneNumber fromVC:(UIViewController *)vc;

+ (NSString *)getCurrentVersion;

+ (void)dispatch_asyn_main:(void (^)(void))call NS_AVAILABLE(10_7, 5_0);

+ (instancetype)shareInstance;

+ (CGFloat)getlabeHeight:(UIFont *)font text:(NSString *)text width:(CGFloat)width;

+ (CGFloat)getlabeWidth:(UIFont *)font text:(NSString *)text;

/**  计算代码执行时间  */
+ (double)calculateCodeExecuteTime:(void (^)(void))executeBlock;

/*********网络模块*****/
#pragma mark - oppo
// 设置属性
+ (void)setPropertiesSiid:(long)siid jsonArrayIid:(NSString *)arr deviceProperties:(NSString *)deviceProperties success:(void (^)(id data))success failed:(void (^)(id code, id msg))failed;

+ (void)queryDevicePropertiesSiid:(long)siid jsonArrayIid:(NSString *)arr deviceProperties:(NSString *)deviceProperties success:(void (^)(id data))success failed:(void (^)(id code, id msg))failed;

// action调用
+ (void)actionCall:(long)siid iid:(int)iid pbBase64:(NSString *)pbBase64 success:(void (^)(id data))success failed:(void (^)(id code, id msg))failed;

// 封装系统弹框

// message文本对齐 且可选择是弹框方式还是底部弹出选择方式
+ (void)alert_tip:(NSString *)title andMessage:(NSString *)message andcancel:(NSString *)cancel_title andcancelColor:(UIColor *)cancelColor andsure:(NSString *)sure_title andsureColor:(UIColor *)sureColor andviewController:(UIViewController *)vc andsure_click:(sure_click)sure_click_block andcancel_click:(cancel_click)cancel_click_block andtitleAlignment:(NSTextAlignment)title_alignment andmessage_textAlignment:(NSTextAlignment)text_alignment andpreferredStyle:(UIAlertControllerStyle)preferredStyle;

// 二进制转字符串二进制
+ (NSString *)loopsIntExplain:(UInt32)loopsInt;

// 二进制字符串转星期字符串
+ (NSDictionary *)getTimeSub:(NSString *)loops;
+ (NSString *)getNoDisturbingPeriodTimeSub:(NSString *)loops;
/**字符串反转*/
+ (NSString *)reverseStringAction:(NSString *)loops;
@end

NS_ASSUME_NONNULL_END
